<?php
    $item_menu[0] = 5;
    $item_menu[1] = 1;
    $title = 'Editar Familias';    
    if (!defined('URL')) { include('header.php'); }
	if (!isset($_SESSION["admin"])) {redirect("login.php");	exit(); }


    $submit = request('submit','');
	$id     = request('id',0);


    if (!empty($submit)) {

        include('familias_guardar.php');

    } else {
    	$cond 	 = "select * from familias where id=".$id;
    	$rs 	 = $db->SelectLimit($cond, 1);
    	$Familia = $rs->FetchRow();

    }


?>



<?php	if(!empty($_SESSION['Msg'])) {   echo mensaje_ok($_SESSION['Msg']);	$_SESSION['Msg']=''; } ?>

<center>
<form name='form1' action='familias_editar.php?id=<?=$id;?>' method='post' accept-charset="utf-8"> 
<table width='1000' cellpadding='3' cellspacing='3' border='0' style="border-width:1px; border-style:solid; border-color:#000000">
	<tr bgcolor='#0271E3' >
		<td colspan='2' align='center'>
			<span style="color:#FFFFFF; font-weight:bold; font-size:14px;">Agregar o Modificar una Familia</span></td>
	</tr>


    <tr><td colspan='2'>	

        	<table width='100%'>
        		<tr>
    				<td width='100' align='right'><span style="color:#000000; font-weight:bold; font-size:12px;\">Nombre:</span></td>									
                    <td width='550' align='left'>
                        <input type='text'  name='nombre1' id="nombre1" value="<?php echo $Familia['nombre1'];?>" style='width:500px;' maxlength='200' />
                     </td>
    			</tr>
    			<tr >
    				<td align='right'><span style="color:#000000; font-weight:bold; font-size:12px;\">URL Amigable:</span></td>
                    <td align='left'><input type='text' id='urlamigable1'  name='urlamigable1' value='<?php echo $Familia['urlamigable1'];?>' style='width:500px;' maxlength='255' /></td>
    			</tr>
    
    			<tr >
    				<td align='right'><span style="color:#000000; font-weight:bold; font-size:12px;\">Keywords:</span></td>
                    <td align='left'><input type='text' name='keywords1' id='keywords1' value='<?php echo $Familia['keywords1'];?>' style='width:500px;' maxlength='255' /></td>
    			</tr>
                <tr >
                    <td style="color:#000000; font-weight:bold; font-size:12px;text-align:right;">Descripcion:<br><small>Max.250caract</small></td>
                    <td align='left'><textarea name='descripcion' id='descripcion' style='width:500px; height:150px;'><?php echo $Familia['descripcion'];?></textarea></td>
                </tr>
    
	<tr> 
	   	<td  class='ctitulo'>Miniatura:<small style='font-size:10px;'><br>jpg o png<br>240px * 120px</small></td>
        <td align='left' valign='top' width='100%'>
            <?php 
            	$ajaxupload['tabla'] = 'familias';
            	$ajaxupload['campo'] = 'id';
                $ajaxupload['id']    = $Familia['id'];
                $ajaxupload['cual']  = 'miniatura';
                //$ajaxupload['identificador']  = $identificador;
                $ajaxupload['donde_subir']    = PROD_SUBIR_FOTOS;
                $ajaxupload['donde_ver']      = PROD_VER_FOTOS;
                $ajaxupload['tn_ancho'] = 0;
    			$ajaxupload['tn_alto']  = 0;
    			$ajaxupload['ancho']    = 300;
    			$ajaxupload['alto']     = 225;
    			$datos_ajaxupload = base64_encode( serialize($ajaxupload) );
            ?>
			<iframe src='<?php echo URL;?>/admin/upload_familia.php?data=<?php echo $datos_ajaxupload;?>' width='500' height='130' frameborder='0'></iframe>
        </td>
    </tr>

                <tr >
                    <td style="color:#000000; font-weight:bold; font-size:12px;text-align:right;">Slide</td>
                    <td align='left'>
                        <select name='slide_id'>
                            <option value='0'> Seleccione una banner</option>
                            <?php 
                                $cond   = "select * from slides order by nombre ASC";
                                $rs     = $db->Execute($cond);
                                $banner = $rs->GetRows();
                                foreach($banner as $b){
                                    if ($b['id'] == $Familia['slide_id']){$sel='selected=selected';} else {$sel='';}
                                    echo "<option value='{$b['id']}' $sel> {$b['nombre']}</option>";  
                                }
                            ?>

                        </select>
                    </td>
                </tr>

    			<tr>
    				<td align='right'><span style="color:#000000; font-weight:bold; font-size:12px;">Sumario<br />

    				<td align='left'>
                        <textarea name='cuerpo1' id='cuerpo1' style="width:800px; height:350px;"  ><?php echo $Familia['cuerpo1'];?></textarea>
                    
                    </td>
    			</tr>

           
            </table>




        <hr/>

	</td></tr>
	<tr bgcolor='#FFFFFF' >
		<td align='center' colspan='2'>
			<input type='hidden' name='id' value='<?php echo $id;?>' />
			<input type='submit' name='submit' value='<< Guardar los cambios >>'/>
		</td>
	</tr>
</table>
</form>
</center>
